package org.springframe.context;

/**
* @package  org.springframe.context
* @classname AnnotationApplicationContext
* @description 注解类Bean容器
* @version 1.0
* @author luoweiwei
* @date  2021-04-23 15:10:24
*/
public class AnnotationApplicationContext extends AbstractApplicationContext {


    public AnnotationApplicationContext(Class<?> configClass) {
        super(configClass);
        refresh();
    }

    @Override
    public Object getBean(String beanName) {
        try {
            return super.getBean(beanName);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
    /**
     * 加载上下文
     * 1.扫描配置类
     * 2.生成beanDefinition集合
     * 3.生成bean放入单例池
     * 4.beanPostProcessor实现
     * 5.AOP实现
     */
    public void refresh(){
        try {
            loadBeanDefinition();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
